package com.shop.cereshop.agent.service.product.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.shop.cereshop.agent.dao.product.AgentProductSkuDAO;
import com.shop.cereshop.agent.service.product.AgentProductSkuService;
import com.shop.cereshop.commons.domain.agentProduct.CereAgentProductSku;
import org.springframework.stereotype.Service;

@Service
public class AgentProductSkuServiceImpl extends ServiceImpl<AgentProductSkuDAO, CereAgentProductSku>
    implements AgentProductSkuService {

  @Override
  public void rollbackStock(Long skuId, Integer buyNumber) {
    // 使用SQL基础mapper更新库存
    baseMapper.update(null,
        new UpdateWrapper<CereAgentProductSku>()
            .setSql("stock = stock + " + buyNumber)
            .eq("sku_id", skuId));
  }
}